package com.my.test.util;

import java.sql.*;

/**
 * Created by Administrator on 2017/7/31.
 */
public class JDBCUtils {
    static{
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection(){
        Connection con = null; //表示数据库的连接对象
        try {
            con = DriverManager.getConnection("jdbc:mysql://192.168.48.128:3306/test?useUnicode=true&amp;characterEncoding=utf8","root","houzhangbo"); //2、连接数据库
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return con;
    }
    public static void main(String[] args){
        PreparedStatement stmt = null;
        try {
            stmt = getConnection().prepareStatement("");
            stmt.executeQuery();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
